翻訳と辞書
Words near each other
・ "O" Is for Outlaw
・ "O"-Jung.Ban.Hap.
・ "Ode-to-Napoleon" hexachord
・ "Oh Yeah!" Live
・ "Our Contemporary" regional art exhibition (Leningrad, 1975)
・ "P" Is for Peril
・ "Pimpernel" Smith
・ "Polish death camp" controversy
・ "Pro knigi" ("About books")
・ "Prosopa" Greek Television Awards
・ "Pussy Cats" Starring the Walkmen
・ "Q" Is for Quarry
・ "R" Is for Ricochet
・ "R" The King (2016 film)
・ "Rags" Ragland
・ ! (album)
・ ! (disambiguation)
・ !!
・ !!!
・ !!! (album)
・ !!Destroy-Oh-Boy!!
・ !Action Pact!
・ !Arriba! La Pachanga
・ !Hero
・ !Hero (album)
・ !Kung language
・ !Oka Tokat
・ !PAUS3
・ !T.O.O.H.!
・ !Women Art Revolution


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

option type : ウィキペディア英語版
option type

In programming languages (especially functional programming languages) and type theory, an option type or maybe type is a polymorphic type that represents encapsulation of an optional value; e.g., it is used as the return type of functions which may or may not return a meaningful value when they are applied. It consists of either an empty constructor (called ''None'' or ''Nothing''), or a constructor encapsulating the original data type A (written ''Just'' A or ''Some'' A). Outside of functional programming, these are known as nullable types.
* In the Haskell language, the option type (called ''Maybe'') is defined as .
* In the Idris language, the option type is also defined as .
* In the Agda language, the option type is called Maybe with variants nothing and just a.
* In the Coq language, the option type is defined as .
* In the OCaml language, the option type is defined as type 'a option = None | Some of 'a.
* In the Scala language, the option type is defined as parameterized abstract class '.. Option() = if (x == null) None else Some(x)...
* In the Standard ML language, the option type is defined as datatype 'a option = NONE | SOME of 'a.
* In the Rust language, it is defined as enum Option .
* In the Swift language, it is defined as enum Optional but is generally written as T? and is initialized with either a value or nil.
* In the Julia language, the option type is called Nullable.
* In the Java language since version 8, the option type is defined as parameterized final class Optional.
* In the C++ language proposed extensions, the option type is defined as the template class template class optional.
In type theory, it may be written as: A^ = A + 1.
In languages that have tagged unions, as in most functional programming languages, option types can be expressed as the tagged union of a unit type plus the encapsulated type.
In the Curry-Howard correspondence, option types are related to the annihilation law for ∨: x∨1=1.
An option type can also be seen as a collection containing either a single element or zero elements.
== The option monad ==
The option type is a monad under the following functions:
:\text\colon A \to A^ = a \mapsto \text \, a
:\text\colon A^ \to (A \to B^) \to B^ = a \mapsto f \mapsto \begin \text & \text \ a = \text\\ f \, a' & \text \ a = \text \, a' \end
We may also describe the option monad in terms of functions ''return'', ''fmap'' and ''join'', where the latter two are given by:
:\text \colon (A \to B) \to A^ \to B^ = f \mapsto a \mapsto \begin \text & \text \ a = \text\\ \text \, f \, a' & \text \ a = \text \, a' \end
:\text \colon \to A^ = a \mapsto \begin \text & \text \ a = \text\\ \text & \text \ a = \text \, \text\\ \text \, a' & \text \ a = \text \, \text \, a' \end
The option monad is an additive monad: it has ''Nothing'' as a zero constructor and the following function as a monadic sum:
:\text \colon A^ \to A^ \to A^ = a_1 \mapsto a_2 \mapsto \begin \text & \text \ a_1 = \text \and a_2 = \text\\ \text \, a'_2 & \text \ a_1 = \text \and a_2 = \text \, a'_2 \\ \text \, a'_1 & \text \ a_1 = \text \, a'_1 \end
In fact, the resulting structure is an idempotent monoid.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「option type」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.